<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>编辑帐号</title>
<link href="./css/common.css" rel="stylesheet" />
<link href="../../css/buttons.css" rel="stylesheet" />
<script type="text/javascript" src="../../js/util.js"></script>
<script type="text/javascript" src="../../js/new-ajax.js"></script>
<script type="text/javascript" src="../../js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
$(function() {
	var url = "${pageContext.request.contextPath}/admin_findAdminRole.action";
	$.post(url,function(data){
		initRoleList(dqbb.$("role"),0,0);
		function initRoleList(obj,pid,step){
			$(data).each(function(){
				if(pid==this.pid){
					obj.options[obj.options.length]=new Option(stepToSpace(step)+this.roleName,this.id,true,false);
					initRoleList(obj,this.id,step+1);
				}
			})
		}
	},"json")
	
})
function checkForm(frm){
	var role=frm['role'];
	var username=frm['username'];
	var password=frm['password'];
	var password1=frm['password1'];
	var realname=frm['realname'];
	if(role.value.trim().length<1){
		alert("请选择角色");
		role.focus();
		return false;
	}
	if(username.value.trim().length<1){
		alert("帐号是必须填写的");
		username.select();
		return false;
	}
	if(password.value.trim().length<1){
		alert("密码是必须填写的");
		password.select();
		return false;
	}
	if(password1.value.trim().length<1){
		alert("重复密码是必须填写的");
		password1.select();
		return false;
	}
	if(password1.value.trim() != password.value.trim()){
		alert("两次密码不一致");
		password.value="";
		password1.value="";
		password.select();
		return false;
	}
	if(realname.value.trim().length<1){
		alert("姓名是必须填写的");
		realname.select();
		return false;
	}
	return true;
}
function stepToSpace(step){
	var buffer="";
	for(var i=0;i<step;i++){
		buffer+="　　";//注意，这里使用了全角空格！
	}
	return buffer;
}

</script>
</head>
<body>
<form action="#" method="post" id="editForm" onsubmit="return checkForm(this)">
<table cellpadding="0" cellspacing="1" border="0" width="100%">
	<tr class="th">
		<td colspan="2">录入帐号</td>
	</tr>
	<tr class="tb">
		<td>角色：</td>
		<td><select name="role" id="role">
			<option value="">==选择角色==</option>
		</select></td>
	</tr>
	<tr class="tb">
		<td width="80">帐号：</td>
		<td><input type="text" name="username" id="username" /></td>
	</tr>
	<tr class="tb">
		<td>密码：</td>
		<td><input type="password" name="password" id="password" /></td>
	</tr>
	<tr class="tb">
		<td>重复密码：</td>
		<td><input type="password" name="password1" id="password1" /></td>
	</tr>
	<tr class="tb">
		<td>姓名：</td>
		<td><input type="text" name="realname" id="realname" /></td>
	</tr>
	<tr class="tb">
		<td>备注：</td>
		<td><textarea name="remark" id="remark" cols="80" rows="10"></textarea></td>
	</tr>
	
	<tr class="tf">
		<td colspan="2">
			<input type="submit" value="提交" class="submit"/>
			<input type="reset" value="重置" class="reset"/>
		</td>
	</tr>
</table>
</form>
</body>
</html>